<script setup>
import storage from '@/utils/storage.js'
const router = useRouter()

const loginInfo = reactive({
  id: '',
  password: ''
})

const login = () => {
  storage.set('token', 'jlasjodusoaulj')
  router.push({ path: '/' })
}
</script>

<template>
  <div class="login-container">
    <section class="login-form">
      <div class="form-item">
        <input
          v-model="loginInfo.id"
          type="text"
          required
        >
        <label for="">账号</label>
      </div>
      <div class="form-item">
        <input
          v-model="loginInfo.password"
          type="password"
          required
        >
        <label for="">密码</label>
      </div>
      <n-button
        strong
        secondary
        color="#fff"
        size="large"
        @click="login"
      >
        起飞
      </n-button>
    </section>
  </div>
</template>

<style lang='scss' scoped>
.login-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: linear-gradient(
    45deg,
    rgba(254, 172, 94, 0.5),
    rgba(199, 121, 208, 0.5),
    rgba(75, 192, 200, 0.5)
  );
  .login-form {
    width: 450px;
    height: 260px;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: 8px;
    .form-item {
      height: 80px;
      width: 80%;
      display: flex;
      align-items: flex-end;
      justify-content: center;
      position: relative;
      &::after {
        content: " ";
        position: absolute;
        width: 0;
        height: 2px;
        bottom: 0;
        left: 0;
        background-color: #728fce;
        transition: all 0.5s;
      }
      > input {
        width: 100%;
        height: 30px;
        border-width: 0 0 2px 0;
        border-color: #fff;
        background-color: transparent;
        &:focus {
          outline: none;
        }
      }
      > label {
        position: absolute;
        bottom: 0;
        left: 0;
        color: #fff;
        font-size: 18px;
        transition: all 0.3s;
      }
      // 选中后显示底部条
      &:focus-within {
        &::after {
          width: 100%;
        }
      }
      // 选中后或填写后上移30px, 是否填写利用input[required]属性，可以用valid选中
      &:focus-within label,
      input:valid ~ label {
        transform: translateY(-30px);
        font-size: 14px;
        color: #728fce;
      }
    }
  }
  .n-button {
    margin-top: 25px;
    width: 70%;
    background-color: #728fce;
  }
}
</style>
